-
Notifications
You must be signed in to change notification settings - Fork 31
Return TIMESTAMP types as timezone-aware native Python datetime objects
#445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
TIMESTAMP types as timezone-aware native Python datetime objectsTIMESTAMP types as timezone-aware native Python datetime objects
c2c0bfc to
b8bc5e7
Compare
matriv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! It looks good, I have some comments around docs.
amotl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear Marios,
I've added some commits and hopefully addressed your suggestions well. Please let me know about anything missing, or where the patch could be improved further.
With kind regards,
Andreas.
matriv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. thank you! Left a comment about a test method name.
349b92e to
4c0fcb9
Compare
33ecbf3 to
4e88a10
Compare
TIMESTAMP types as timezone-aware native Python datetime objectsTIMESTAMP types as timezone-aware native Python datetime objects
f635078 to
3f79183
Compare
4c0fcb9 to
9ef9d61
Compare
TIMESTAMP types as timezone-aware native Python datetime objectsTIMESTAMP types as timezone-aware native Python datetime objects
135caf7 to
eba6f89
Compare
98630d0 to
48d8bd7
Compare
48d8bd7 to
77dc5df
Compare
This is additional API convenience based on the data type converter
machinery. A `time_zone` keyword argument can be passed to both the
`connect()` method, or when creating new `Cursor` objects.
The `time_zone` attribute can also be changed at runtime on both the
`connection` and `cursor` object instances.
Examples:
- connect('localhost:4200', time_zone=pytz.timezone("Australia/Sydney"))
- connection.cursor(time_zone="+0530")
77dc5df to
8d8a6d1
Compare
About
When requested, make the driver return timezone-aware native Python
datetimeobjects for CrateDB'sTIMESTAMPtypes. The user can easily supply the desired time zone by different means.Rationale
@mfussenegger asked at #442 (review):
I shared some initial thoughts about it at #442 (review) ff., and finally settled with this implementation, separately from the baseline implementation for the data type converter.
Details
This patch adds additional convenience based on the data type converter machinery added with #442.
time_zonekeyword argument can be passed to both theconnect()method, or when creating newCursorobjects.time_zoneattribute can also be changed at runtime on both theconnectionandcursorobject instances.Different ways to populate the
time_zonevalue are supported. Some examples::datetime.timezone.utcdatetime.timezone(datetime.timedelta(hours=7), name="MST")pytz.timezone("Australia/Sydney")zoneinfo.ZoneInfo("Australia/Sydney")+0530(UTC offset in string format)Acknowledgements
This interface was inspired by the DBAPI drivers for MySQL and Elasticsearch. Thanks.
Synopsis
Use
time_zoneargument when creating a new connection. Here, use apytz.timezoneobject.Use
time_zoneargument when creating a new cursor. Here, use an UTC offset string.References
Cursorobject #442Backlog